#include <iostream>
using namespace std;

void multbigint(int a[], int n, int b[], int m)
{
	int *r = new int[n+m];
	memset(r, 0, sizeof(int)*(n+m));
	for(int i=0; i<m; i++)
	{
		int carry = 0;
		for(int j=0; j<n; j++)
		{
			int temp = b[i] * a[j] + r[i+j] + carry;
			carry = temp / 10;
			r[i+j] = temp % 10;
		}
		r[i+n] = carry; //shit!
	}
	int k = m+n-1;
	while(r[k]==0)
		k--;
	for(; k>=0 ; k--)
		cout<<r[k];
	cout << endl;
	delete[] r;	
}


int main()
{
	int a[] = {5,6,3}; //365
	int b[] = {2,8,5,4}; //4582
	multbigint(a, 3, b, 4);
	return 0;
}
